package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.HotCategoryProductRequest;
import com.ytjj.qmyx.admin.service.HotCategoryProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 
 * 
 * @Version: 1.0
 *
 * 单品爆款商品管理
 */
@RestController
@RequestMapping("/hotCategoryProduct")
public class HotCategoryProductController {

    @Resource
    private HotCategoryProductService hotCategoryProductService;

    @GetMapping("/list")
    @OperLog(operModule = "单品爆款商品管理", operDesc = "商品管理列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult selectList(HotCategoryProductRequest hotCategoryProductRequest) {
        return CommonResult.success(hotCategoryProductService.selectList(hotCategoryProductRequest));
    }

    @GetMapping("/insert")
    @OperLog(operModule = "单品爆款商品管理", operDesc = "新增商品", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult insertHotCategoryProduct(@RequestParam Integer hotProductCategoryId, @RequestParam Integer productId, @RequestParam Integer sort) {
        return CommonResult.success(hotCategoryProductService.insertHotCategoryProduct(hotProductCategoryId, productId, sort));
    }

    @GetMapping("/updateSort")
    @OperLog(operModule = "单品爆款商品管理", operDesc = "修改排序", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateSort(@RequestParam Integer categoryProductId, @RequestParam Integer sort) {
        return CommonResult.success(hotCategoryProductService.updateSort(categoryProductId, sort));
    }

    @GetMapping("/removeData")
    @OperLog(operModule = "单品爆款商品管理", operDesc = "移除", operType = SysLogConstants.OPERATION_DELETE)
    public CommonResult removeData(@RequestParam Integer categoryProductId) {
        return CommonResult.success(hotCategoryProductService.removeData(categoryProductId));
    }
}
